package com.mck.mapper;

import com.mck.entity.Notice;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

@Mapper
public interface NoticeMapper {

    // 查询所有公告
    @Select("select id, title, content, type, version, important, status, create_time, update_time, create_by, update_by from system_notice order by create_time desc ")
    List<Notice> getNotice();

    // 添加公告
    @Insert("insert into system_notice(title, content, type, version, important, status, create_time, update_time, create_by, update_by) values(#{title}, #{content}, #{type},#{version}, #{important}, #{status}, #{createTime}, #{updateTime}, #{createBy}, #{updateBy})")
    void addNotice(Notice notice);

    // 修改公告
    @Update("update system_notice set title = #{title}, content = #{content}, type = #{type}, important = #{important}, status = #{status}, update_time = #{updateTime}, update_by = #{updateBy} where id = #{id}")
    void updateNotice(Notice notice);
}
